/*LICENSE_BEGIN
 * ******************************************************************
 * All original parts of SoccerScope2003 have copyright (2003) by
 * Team YowAI, represented by Mr. Shuhei Shiota
 * The Department of Creative Informatics
 * The Graduate School of Information Science and Technology
 * The University of Tokyo
 * 
 * Additional classes (except libraries in /lib) were developed by 
 * the Dainamite Robocup-Team of the DAI-Labor, TU-Berlin 
 * (www.dai-labor.de)
 * 
 * Extended/new classes/packages are:
 *   soccerscope.analyzer.LogfileAnalyzer
 *   soccerscope.daistatistic.*
 *   soccerscope.daistatistic.charts.*
 *   soccerscope.daistatistic.tools.*
 *   soccerscope.db.*
 *   soccerscope.dialog.*
 *   soccerscope.model.PlayerWorldModel
 *   soccerscope.model.SimplePlayer
 *   soccerscope.net.AgentConnector
 *   soccerscope.training.*
 *   soccerscope.training.conditions.*
 * ******************************************************************
LICENSE_END*/
package soccerscope.view.layer;

import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JPanel;

import soccerscope.model.ClientScene;
import soccerscope.model.Param;
import soccerscope.util.geom.Point2f;
import soccerscope.util.geom.Vector2f;
import soccerscope.view.FieldPane;

public class NoNoiseLayer extends Layer {

	public NoNoiseLayer(FieldPane fieldPane, boolean enable) {
		super(fieldPane, enable);
		this.drawPoint = new Point2f();
		this.vel = new Vector2f();
	}

	@Override
	public String getLayerName() {
		return "No Noise";
	}

	@Override
	public JPanel getConfigPanel() {
		return null;
	}

	private int limit = 10;

	private Point2f drawPoint;

	private Vector2f vel;

	@Override
	public void draw(Graphics g) {
		if (!this.enable)
			return;

		ClientScene clientScene = this.fieldPane.getScene();
		float ballMagnify = this.fieldPane.getBallMagnify();
		float playerMagnify = this.fieldPane.getPlayerMagnify();

		float ballR = Param.BALL_SIZE * ballMagnify;
		// float playerR = Param.PLAYER_SIZE * playerMagnify;

		g.setColor(Color.blue);
		this.vel.set(clientScene.ball.vel);
		this.drawPoint.add(clientScene.ball.pos, this.vel);
		for (int offset = this.limit; offset > 0; offset--) {
			drawCircle(g, this.drawPoint, ballR);
			this.vel.scale(Param.BALL_DECAY);
			this.drawPoint.add(this.vel);
		}
		drawCircle(g, this.drawPoint, ballR);
		drawLine(g, clientScene.ball.pos, this.drawPoint);
	}
}
